import { Zombie } from "./models/Zombie";
import packageInfo from "../package.json"
import { IPage } from "./pages/IPage";
import { Page } from "./pages/Page";
import { FunctionModel } from "./models/FunctionModel";
// import {page as p3} from"./pages/01-ui/index3" 

console.log(`${packageInfo.name}:${packageInfo.version}(${packageInfo.build}),hello,world!`);
// object 和 interface 是一样的. 但是Class对象则是类对象.不一样.
let p1 = require("./pages/01-ui/index") as Page
let p2 = require("./pages/01-ui/index2") as IPage
console.log(p1.showPage);
console.log(p2);

p1.showPage();
p2.showPage();

// const pagePath1 = "src/pages/01-u1/index.ts";
// const m1 = require(pagePath1);
// console.log(m1);
function initFunctions(): FunctionModel {
    let f0 = new FunctionModel("", "");
    let f1 = new FunctionModel("ui", "./pages/01-ui/index");
    f0.addSubFunction(f1);
    return f0;
}
/**
 * 展示FunctionModel
 * 有subs则显示subs的列表,没有则执行当前function的page.
 * @param f 
 */
function renderData(f: FunctionModel) {
    if (f.subs.length) {
        for (let i = 0; i < f.subs.length; i++) {
            let subf = f.subs[i];
            console.log(`${i}: ${subf.name} ${subf.detail??""}`)
        }
    }
    else {
        let p = require(f.page) as IPage
        p.showPage();
    }
}


let currentF = initFunctions();

renderData(currentF);
